C
C     ..................................................................
C
C        SUBROUTINE PPRCN
C
C        PURPOSE
C           TO COMPUTE, GIVEN TWO PERMUTATION VECTORS IP1 AND IP2, THE
C           COMPOSITION IP2(IP1) AND THE CONJUGATE IP1(IP2(IP1 INVERSE))
C           OF IP2 BY IP1.  (SEE THE GENERAL DISCUSSION FOR DEFINITIONS
C           AND NOTATION.)
C
C        USAGE
C           CALL PPRCN(IP1,IP2,IP3,N,IPAR,IER)
C
C        DESCRIPTION OF PARAMETERS
C           IP1  - GIVEN PERMUTATION VECTOR (DIMENSION N)
C           IP2  - GIVEN PERMUTATION VECTOR (DIMENSION N)
C           IP3  - RESULTING PERMUTATION VECTOR (DIMENSION N)
C           N    - DIMENSION OF VECTORS IP1, IP2 AND IP3
C           IPAR - INPUT PARAMETER
C                  IPAR NON-NEGATIVE - COMPUTE IP2(IP1)
C                  IPAR NEGATIVE     - COMPUTE IP1(IP2(IP1 INVERSE))
C           IER  - RESULTING ERROR PARAMETER
C                  IER=-1  -  N IS NOT POSITIVE
C                  IER= 0  -  NO ERROR
C                  IER= 1  -  IP1 AND IP2 ARE NOT BOTH PERMUTATION
C                             VECTORS ON 1,...,N
C
C        REMARKS
C           (1)  IF IER=-1 THERE HAS BEEN NO COMPUTATION.
C           (2)  IF IER=1, THEN COMPUTATION HAS BEEN UNSUCCESSFUL DUE TO
C                ERROR AND THE PARTIAL RESULTS FOUND IN IP2 ARE USELESS.
C           (3)  IP3 CANNOT HAVE THE SAME STORAGE ALLOCATION AS IP1 OR
C                IP2.
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           PERM
C
C        METHOD
C           SUBROUTINE PERM IS USED TO CHECK THAT IP1 AND IP2 ARE PERMU-
C           TATION VECTORS.  IF IP2(IP1) IS COMPUTED, IP3(I) IS SET TO
C           IP2(IP1(I)) FOR I=1,...,N.  IF IP1(IP2(IP1 INVERSE)) IS
C           COMPUTED, FIRST IP3 IS SET TO IP1 INVERSE BY SUBROUTINE PERM
C           AND THEN IP3(I) IS SET TO IP1(IP2(IP3(I))) FOR I=1,...,N.
C
C     ..................................................................
C
      SUBROUTINE PPRCN(IP1,IP2,IP3,N,IPAR,IER)
C
C
      DIMENSION IP1(1),IP2(1),IP3(1)
C
C        CHECK THAT N IS POSITIVE AND THAT IP2 IS A PERMUTATION VECTOR
      CALL PERM(IP2,IP3,N,-1,IER)
C
C        TEST IER TO SEE IF THERE IS AN ERROR
      IF(IER)7,1,7
C
C        CHECK THAT IP1 IS A PERMUTATION VECTOR AND COMPUTE IP1 INVERSE
    1 CALL PERM(IP1,IP3,N,-1,IER)
C
C        TEST IER TO SEE IF THERE IS AN ERROR
      IF(IER)7,2,7
C
C        TEST IPAR FOR THE DESIRED OPERATION
    2 IF(IPAR)3,5,5
C
C        COMPUTE IP1(IP2(IP1 INVERSE))
    3 DO 4 I=1,N
      K=IP3(I)
      J=IP2(K)
    4 IP3(I)=IP1(J)
      RETURN
C
C        COMPUTE IP2(IP1)
    5 DO 6 I=1,N
      K=IP1(I)
    6 IP3(I)=IP2(K)
    7 RETURN
      END
